from django.db import models
from django.core.validators import MinValueValidator
from django.core.validators import MaxValueValidator


class Coupon(models.Model):

    """ Этот класс представляет купон на товар """

    code = models.CharField(max_length=50, unique=True)
    valid_from = models.DateTimeField()
    valid_to = models.DateTimeField()
    discount = models.IntegerField(
            validators=[MinValueValidator(9), MaxValueValidator(100)])
    active = models.BooleanField()

    def __str__(self):

        return self.code
